package com.tensquare.qa.controller;

import com.tensquare.entity.Result;
import com.tensquare.entity.StatusCode;
import com.tensquare.qa.pojo.Problem;
import com.tensquare.qa.service.ProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zzb
 * @create 2021/2/21
 */
@RestController
@RequestMapping("problem")
public class ProblemController {
    @Autowired
    private ProblemService problemService;
    //查询最新问题列表
    @GetMapping("newlist/{labelid}/{page}/{size}")
    public Result newlist(@PathVariable Integer labelid,@PathVariable Integer page,@PathVariable Integer size){
        List<Problem> problems = problemService.newlist(labelid,page,size);
        return new Result(true, StatusCode.OK,"查询最新问题列表成功",problems);
    }

    //热门问答列表
    @GetMapping("hotlist/{labelid}/{page}/{size}")
    public Result hotlist(@PathVariable Integer labelid,@PathVariable Integer page,@PathVariable Integer size){
        List<Problem> problems = problemService.hotlist(labelid,page,size);
        return new Result(true,StatusCode.OK,"热门问答列表成功",problems);
    }
}
